package com.zh.note.huawei.onehundred.分苹果;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author: zhanghuan
 * @date: 2023/8/21 13:22
 * @description: create it
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        // int n = scanner.nextInt();
        // String input = scanner.nextLine();
        int n = 8;
        String input = "7258 6579 2602 6716 3050 3564 5396 1773";
        // int n = 3;
        // String input = "3 5 6";
        int[] nums = Arrays.stream(input.split(" ")).mapToInt(Integer::parseInt).toArray();
        int x = 0;
        for (int i = 0; i < nums.length; i++) {
            x ^= nums[i];
        }
        if (x == 0) {
            int res = 0;
            Arrays.sort(nums);
            // 为啥最小的是一堆，剩下的是一堆？
            for (int i = 1; i < nums.length; i++) {
                res += nums[i];
            }
            System.out.println(res);
        } else {
            System.out.println(-1);
        }
    }
}
